//
//  XXJSubTagCell.m
//  gosh
//
//  Created by 许小军 on 16/9/24.
//  Copyright © 2016年 wyzc. All rights reserved.
//

#import "XXJSubTagCell.h"
#import "XXJSugModel.h"
#import <UIImageView+WebCache.h>
@interface XXJSubTagCell ()

@property (weak, nonatomic) IBOutlet UIImageView *headImage;
@property (weak, nonatomic) IBOutlet UILabel *nameLable;

@property (weak, nonatomic) IBOutlet UILabel *numLable;


@end
@implementation XXJSubTagCell

- (void)awakeFromNib {
    // Initialization code
}


-(void)setModel:(XXJSugModel *)model
{
    _model=model;
    _nameLable.text=model.theme_name;
    [self resolveNum];
    [_headImage sd_setImageWithURL:[NSURL URLWithString:model.image_list] placeholderImage:[UIImage imageNamed:@"defaultUserIcon"] options:SDWebImageCacheMemoryOnly completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
        UIGraphicsBeginImageContextWithOptions(image.size, NO, 0);
        UIBezierPath * path=[UIBezierPath bezierPathWithOvalInRect:CGRectMake(0, 0, image.size.width, image.size.height)];
        [path addClip];
        [image drawAtPoint:CGPointZero];
        image=UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
        _headImage.image=image;
    }];
    
    
    
}


-(void)resolveNum
{
    NSString * str=[NSString stringWithFormat:@"%@人订阅",_model.sub_number];
    NSInteger number=_model.sub_number.integerValue;
    if (number>10000) {
        CGFloat numF=number/10000.0;
        str=[NSString stringWithFormat:@"%1.f万人订阅",numF];
        str=[str stringByReplacingOccurrencesOfString:@".0" withString:@""];
        
    }
    _numLable.text=str;
}






- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
